﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OISTools
{
    public partial class MDIMenu : Form
    {
        private int childFormNumber = 0;

        public MDIMenu()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "窗口 " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void miScriptDebugger_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.ScriptDebugger());
        }

        private void miDBCompare_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.DBCompare());

        }

        private void miCreateScript_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.CreateScript());
        }

        private void miLanguageAnayle_Click(object sender, EventArgs e)
        {
            OpenWindow(new LanguageAnalyse.LanguageCompare());
        }

        private void miTranslateSuggest_Click(object sender, EventArgs e)
        {
            OpenWindow(new LanguageAnalyse.TranslateSuggest());
        }

        private void OpenWindow(Form f1)
        {
            f1.MdiParent = this;
            f1.Show();
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.DBAnalyse());
        }

        private void miReadApfield_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.ReadApfield());
        }

        private void miQueryApfield_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.QueryApfield());
        }

        private void miTask_Click(object sender, EventArgs e)
        {
            OpenWindow(new CreatePGSQLDataScript.TaskList());
        }

 
        private void MDIMenu_Load(object sender, EventArgs e)
        {
            notifyIcon1.Visible = true;
            this.Hide();   

        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Show();
            this.WindowState = FormWindowState.Maximized;
            notifyIcon1.Visible = false;
            this.ShowInTaskbar = true;
        }

 
    }
}
